I'm trying to connect to my database using mongoose and in my console is displaying ' option usefindandmodify is not supproted '. I'm using mongoose 6.0.0
this is my code
mongoose.connect(constants.CONNECTION_URL,
{ useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
})
.then(() => app.listen(constants.PORT, () => console.log(`Server Running on Port ${constants.PORT}`)))
.catch((error) => console.log(error.message));
mongoose.Promise = global.Promise;
can someone suggest me how can I get rid of that? is written with white if matters neither green nor red, white.
Starting with Mongoose version 6, you should not specify that as an option. It will be handled automatically.
useNewUrlParser,useUnifiedTopology,useFindAndModify, anduseCreateIndexare no longer supported options. Mongoose 6 always behaves as ifuseNewUrlParser,useUnifiedTopology, anduseCreateIndexare true, anduseFindAndModifyis false. Please remove these options from your code.
i got this error too , so i fixed that like this
i guess useNewUrlParser, useUnifiedTopology, useFindAndModify are no longer available
mongoose.connect(constants.CONNECTION_URL).then(() => app.listen(constants.PORT, () => console.log(`Server Running on Port ${constants.PORT}`)))
.catch((error) => console.log(error.message));
mongoose.Promise = global.Promise;
mongoose.connect(CONNECTION_URL) .then(() => app.listen(PORT, () => console.log(Server running on port ${PORT})) ).catch((error) => console.log(error.message));
New version of Mongoose don't support useFindAndModify, you don't have to write it in your code, Mongoose by default takes useFindAndModify as false.
just remove useFindAndModify from your code.